package adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Administrator on 2016/5/13.
 *首页底部的ViewPageer的适配器
 */
public class ViewPagerHomeButton extends PagerAdapter{
    private List<View> mList;
    private Context mContext;
    private String mbutton;
    public ViewPagerHomeButton(Context context, List<View> list,String button){
        this.mList = list;
        Log.e("Home","apager_button_VP    "+mList.size());
        this.mContext = context;
        this.mbutton = button;
    }
    @Override public int getCount() {

        if(mbutton.equals("button")){return mList.size();}
        return 0;
    }

    @Override public boolean isViewFromObject(View view, Object object) {
        return object == view;
    }

    @Override public Object instantiateItem(ViewGroup container, final int position) {

        if (mbutton.equals("button")) {container.addView(mList.get(position));
            return mList.get(position);
        }

        return mList.get(position);
    }

    @Override public void destroyItem(ViewGroup container, int position, Object object) {
            if (mbutton.equals("button")){container.removeView(mList.get(position));}
    }
}
